package main

import "fmt"

type Point struct {
	X, Y float64
}

func Distance(p, q Point) float64 {
	return p.X + q.Y
}

// Distance 方法
func (p Point) Distance(q Point) float64 {
	return q.X - p.X
}

func (p *Point) ReplaceY(q float64) {
	p.Y = q
}

func (p *Point) ScaleBy(footer float64)  {
	p.X = footer
	p.Y = footer
}

func main() {

	r := &Point{X: 1.1, Y: 2.2}
	r.ReplaceY(3.3)
	fmt.Println(*r)

	r1 := Point{X: 5.5, Y: 5.6}
	r1.ReplaceY(5.7)
	fmt.Println(r1)

	point := Point{1.0, 2.0}
	point.ScaleBy(1.2)

	p := Point{2.2, 3.3}
	q := Point{5.0, 6.0}
	distance := Point.Distance
	fmt.Println(distance(p, q))
}
